﻿@using OA.Core.Model;
@using OA.Model;
 
@{
    Layout = null;    
}
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>@ViewBag.Title</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="@ViewBag.OssUrl/front/css/admin.css" />
    <link rel="stylesheet" href="@ViewBag.OssUrl/admin/layuiadmin/layui/css/layui.css">
    <script type="text/javascript" src="@ViewBag.OssUrl/js/jquery-3.4.1.min.js"></script>
    <script type="text/javascript" src="@ViewBag.OssUrl/admin/layuiadmin/layui/layui.js"></script>
    <script type="text/javascript">
        var parentUrl = "";
        var currentUrl = "";
        var ossSignatureUrl =  window.location.protocol + "//" + window.location.host+ "/Home/GetOssSignature?Signature=@ViewBag.Signature";
        
    </script>
</head>
<body>
    <div class="fly-panel-user" style="padding:20px 20px 20px 20px;">
        @RenderBody()
    </div>
    <script type="text/javascript">
        var form;       
        layui.use(['form', 'layedit', 'element', 'laydate','autocomplete'], function () {
            form = layui.form
                , layer = layui.layer
                , layedit = layui.layedit
                , laydate = layui.laydate
                , element = layui.element
                , autocomplete = layui.autocomplete;           
            var dateCotrol = $(".mydate");
            if (dateCotrol.length > 0) {
                $.each(dateCotrol, function () {
                    var controlID = $(this).prop("id");
                    var type = $(this).attr("data-type");
                    if (controlID != undefined && controlID != null) {
                        laydate.render({
                            elem: '#' + controlID,
                            type: type
                        });
                    }
                });
            }
            form.on('submit(OAForm)', function (data) {
                $(".mySubmit").prop("disabled", true);
                var index = layer.load(1, {
                    shade: [0.1, '#fff']
                });
                var myFrom = $("#myForm");
                $.post(myFrom.prop("action"), myFrom.serialize(), function (result) {
                    $(".mySubmit").prop("disabled", false);
                    layer.closeAll();
                    if (result.State == 400) {
                        layer.msg(result.Msg);
                        return;
                    }
                    if (result.State == 402) {
                        layer.msg(result.Msg);
                        return;
                    }
                    else {
                        if (result.Msg.startsWith("url:")) {
                            window.location.href = result.Msg.substring(4);
                        }
                        else {
                            layer.msg(result.Msg);
                            if (parentUrl != "") {
                                setTimeout(function () { window.parent.href = parentUrl; }, 1000);
                            }
                            else if (currentUrl != "") {
                                window.location.href = currentUrl;
                            }
                            else {
                                window.parent.RefreshResultList();
                            }
                        }

                    }
                });
                return false;
            });

        });
      
    </script>
</body>
</html>